﻿using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Autofac;
using Volo.Abp.Modularity;

namespace Abp.Web
{
    /// <summary>
    /// 应用程序启动模块
    /// </summary>
    [DependsOn(typeof(AbpAspNetCoreMvcModule))] //AspNetCoreMvc
    [DependsOn(typeof(AbpAutofacModule))] //Autofac依赖注入
    public class AppModule : AbpModule
    {
        public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
            var app = context.GetApplicationBuilder();
            var env = context.GetEnvironment();

            //配置HTTP请求管道
            if(env.IsDevelopment())
            {
                app.UseExceptionHandler("/Error");
                //默认HSTS值是30天
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseRouting();
            app.UseConfiguredEndpoints();
        }
    }
}
